﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:WickedFlame.VecDraw.Base.Controls">

    <SolidColorBrush x:Key="SunkenBackground" Color="#444444" />
    <SolidColorBrush x:Key="HighlightBorderBrush" Color="#808080" />
    <SolidColorBrush x:Key="Shadow" Color="#101010" />
    
    <Style TargetType="{x:Type Button}" x:Key="transparentButton">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Border BorderThickness="0" Background="Transparent">
                            <ContentPresenter VerticalAlignment="{TemplateBinding VerticalAlignment}"
                                              HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
											SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type local:ColorSelector}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ColorSelector}">
                    <Grid>
                        <Border x:Name="PART_ButtonBackground" BorderBrush="Transparent" BorderThickness="1,1,2,2" Background="White" CornerRadius="2">
                            <Path Data="M10,0 L 0,10" Stroke="Red" StrokeThickness="2" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2"/>
                        </Border>

                        <Button x:Name="PART_Button" Style="{StaticResource transparentButton}">
                            <Grid>
                                <Border BorderBrush="Transparent" BorderThickness="1" CornerRadius="2">
                                    <Border.Background>
                                        <SolidColorBrush Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedColor}"/>
                                    </Border.Background>
                                </Border>

                                <Border x:Name="Hl" BorderBrush="{StaticResource HighlightBorderBrush}" BorderThickness="0,0,0,1" CornerRadius="2" />
                                <Border x:Name="Sh" BorderBrush="{StaticResource Shadow}" BorderThickness="0,1,0,0" CornerRadius="2" />
                                
                            </Grid>
                        </Button>

                        <!--<Popup  StaysOpen="False" Name="PART_PopUp" PlacementTarget="{Binding ElementName=Border}" Placement="Bottom">-->
                        <Popup  StaysOpen="False" Name="PART_PopUp" PlacementTarget="{Binding ElementName=PART_Button}" Placement="Bottom">
                            <Border BorderBrush="Black" BorderThickness="1" Background="Transparent">
                                <Grid >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="10"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <Border x:Name="PART_TransparentSelector" BorderBrush="Black" Background="White" BorderThickness="0,0,1,0" Grid.Column="0">
                                        <Path Data="M10,0 L 0,10" Stroke="Red" StrokeThickness="2" VerticalAlignment="center" HorizontalAlignment="Center" Margin="2"/>
                                    </Border>

                                    <ContentPresenter Grid.Column="1" Height="30" Width="150" ContentSource="SwatchImage" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"  />
                                    <Canvas Grid.Column="1" x:Name="PART_SwatchCanvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Transparent"/>
                                    
                                </Grid>
                            </Border>
                        </Popup>
                    </Grid>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsTransparentVisible" Value="false">
                            <Setter TargetName="PART_TransparentSelector" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>